package com.my.study.ext;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.stereotype.Component;

/**
 * 自定义的BeanFactory后置处理器
 *
 * @author Carlos
 * @version 1.0.0
 * @date 2021/11/28 21:07
 */
@Component
public class CustomBeanFactoryPostProcessor implements BeanFactoryPostProcessor {


    @Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
        System.out.println(">>> [CustomBeanFactoryPostProcessor.postProcessBeanFactory] ... <<<");
        int count = beanFactory.getBeanDefinitionCount();
        System.out.println("count = " + count);
        String[] names = beanFactory.getBeanDefinitionNames();
        System.out.println(">>> contains name - start <<<");
        for (String name : names) {
            System.out.println(name);
        }
        System.out.println(">>> contains name - end <<<");
    }
}
